{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
            <!-- <div class="layui-card-header">短信设置</div> -->
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this" onclick="location.href='{:url('index')}'">短信设置</li>
                    <li onclick="location.href='{:url('sendlog')}'">发送记录</li>
                </ul>
            </div>
            <div class="layui-card-body" pad15>

                <div class="layui-form form-label-w8" lay-filter="">

                    <div class="layui-form-item">
                        <label class="layui-form-label">短信状态</label>
                        <div class="layui-input-inline" style="width:300px">
                            <input type="radio" name="info[status]" value="1" title="开启" {if $info && $info['status']==1}checked{/if} />
                            <input type="radio" name="info[status]" value="0" title="关闭" {if empty($info) || $info['status']==0}checked{/if} />
                        </div>
                        <div class="layui-form-mid layui-word-aux"></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信签名</label>
                        <div class="layui-input-inline" style="width:300px">
                            <input class="layui-input" name="info[sign_name]" value="{$info.sign_name|default=''}"/>
                        </div>
                        <div class="layui-form-mid layui-word-aux"></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信接口</label>
                        <div class="layui-input-inline" style="width:300px">
                            <select name="info[smstype]" lay-filter="smstypeset">
                                <option value="ali" {if $info && $info['smstype']=='tengxun'}selected{/if} >阿里云</option>
                                <option value="tengxun" {if $info && $info['smstype']=='ali'}selected{/if} >腾讯云</option>
                                <option value="juchen" {if !$info || ($info['smstype'] != 'juchen')}selected{/if} >巨辰短信</option>
                            </select>
                        </div>
                        <div class="layui-form-mid layui-word-aux"></div>
                    </div>
                    <div id="tengxun" {if condition="empty($info) or $info['smstype'] neq 'ali'"}style="display:none;"{/if} >
                        <div class="layui-form-item">
                            <label class="layui-form-label">AccessKey ID</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[accesskey]" value="{$info['accesskey']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">AccessKey Secret</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[accesssecret]" value="{$info['accesssecret']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">应用SDK AppID</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[sdkappid]" value="{$info['sdkappid']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                    </div>
                    <div id="ali" {if empty($info) || $info['smstype'] != 'tengxun'}style="display:none;"{/if} >
                        <div class="layui-form-item">
                            <label class="layui-form-label">SecretId</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[accesskey]" value="{$info['accesskey']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">SecretKey</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[accesssecret]" value="{$info['accesssecret']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                    </div>
                    <div id="juchen" {if $info && $info['smstype'] != 'juchen'}style="display:none;"{/if} >
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户账号</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[accesskey]" value="{$info['accesskey']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户密码</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[accesssecret]" value="{$info['accesssecret']|default=''}" class="layui-input"/>
                            </div>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="setsms">确认修改</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>
<script>
    layui.use(function() {
        layui.form.on('select(smstypeset)', function(data){
            if(data.value=='tengxun'){
                $('#tengxun').show();
                $('#ali').hide();
                $('#juchen').hide();
            }else if(data.value=='ali'){
                $('#tengxun').hide();
                $('#ali').show();
                $('#juchen').hide();
            }else if(data.value=='juchen'){
                $('#tengxun').hide();
                $('#ali').hide();
                $('#juchen').show();
            }
        })

        layui.form.on('submit(setsms)', function(obj){
            var field = obj.field
            $.post('{:url("save")}',obj.field,function(data){
                dialog(data.msg,data.status);
            })
        })

    })
</script>
</body>
</html>